Branches to one of several specified lines in the program code, depending on the value of a numeric expression.
プログラムコード上に複数の指定行を設けておき、与えられる数値表式を基にして、いずれか 1 つの行に分岐します。
On N GoSub Label1[, Label2[, Label3[,...]]]
On N GoSub Label1[, Label2[, Label3[,...]]]
On NumExpression GoTo Label1[, Label2[, Label3[,...]]]
On NumExpression GoTo Label1[, Label2[, Label3[,...]]]
NumExpression: Any numeric expression between 0 and 255 that determines which of the lines the program branches to. If NumExpression is 0, the statement is not executed. If NumExpression is greater than 0, the program jumps to the label that has a position number that corresponds to the expression (1 = First label; 2 = Second label)
NumExpression: プログラム実行行の分岐先を示す、0 から 255 までの数値表式。NumExpression の指定値が 0 であると、このステートメントは実行されません。NumExpression が 0 よりも大きい場合は、指定値に該当するラベルにプログラム実行行がジャンプします (1 = 最初のラベル; 2 = 次のラベル)。
Label: Target line according to GoTo or GoSub structure.
Label: GoTo および GoSub でラベル付けされたターゲット行。
![]() | The GoTo or GoSub conventions are valid.
分岐方式の指定には GoTo および GoSub が使用できます。 |
Sub ExampleOnGosub
Sub ExampleOnGosub
Dim iVar As Integer
Dim iVar As Integer
Dim sVar As String
Dim sVar As String
iVar = 2
iVar = 2
sVar =""
sVar =""
On iVar GoSub Sub1, Sub2
On iVar GoSub Sub1, Sub2
On iVar GoTo Line1, Line2
On iVar GoTo Line1, Line2
Exit Sub
Exit Sub
Sub1:
Sub1:
sVar =sVar & " From Sub 1 to" : Return
sVar =sVar & " From Sub 1 to" : Return
Sub2:
Sub2:
sVar =sVar & " From Sub 2 to" : Return
sVar =sVar & " From Sub 2 to" : Return
Line1:
Line1:
sVar =sVar & " Label 1" : GoTo Ende
sVar =sVar & " Label 1" : GoTo Ende
Line2:
Line2:
sVar =sVar & " Label 2"
sVar =sVar & " Label 2"
Ende:
Ende:
MsgBox sVar,0,"On...Gosub"
MsgBox sVar,0,"On...Gosub"
End Sub
End Sub